<%@ page import="java.util.*,com.release.utils.*,java.text.*,java.io.*,com.release.bean.*" %>
<% 
String fname=(String)request.getParameter("folder");
//if(name != null)request.setAttribute("filefolder","abc");
//String  filen=(String)request.getParameter("filefolder");
///System.out.println("F O L D E R - - > >  "+filen);
	
try {
		 session = request.getSession();
			System.out.println("user_id" +session.getAttribute("USER_ID"));
			if (session.getAttribute("USER_ID") == null
					|| !((String) session.getAttribute("SESSION_ID"))
							.equals(session.getId())) {
				try {
					response.sendRedirect("LoginPage.jsp");
				} catch (IOException ioe) {
					ioe.printStackTrace();
				}
	
			} else { %>




<HTML>
<HEAD>
<link type="text/css" rel="stylesheet" href="styles/tracker_style.css">
<TITLE>upload Page</TITLE>
</HEAD>

<BODY>
<FORM name="uploadform" action='uploadpage.jsp'  method="post" enctype="multipart/form-data">
<input type="hidden" name="updfile" value="<%=fname%>">
<table>
<tr><td><INPUT type="FILE" name="UPLOADFILE" ></td> 
<td><input type="submit" value="upload" ></td> </tr>
</table>
 </FORM>
<%
	String fileName = "";
	Hashtable htRequest = new Hashtable();
	String upname="" ;
	//System.out.println("upload..name  -->> " + name);
	
	if(request.getContentType()!=null) {
	try {
		System.out.println("--------------"+request.getContentType());
		ParseReqBody pMF = new ParseReqBody(request);
		String param;
		ArrayList fileArrList = new ArrayList();
       // param = pMF.getNextParameter();
		//System.out.println("param  " + param);
		while ((param = pMF.getNextParameter()) != null) {
			System.out.println("param**-----**" + param);
			if(param.equalsIgnoreCase("updfile")) {
				System.out.println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
				upname=pMF.getParameterValue(); 
				System.out.println("file folderr  -->> " + upname);
			}
			if (param.equalsIgnoreCase("UPLOADFILE")) {
				fileName = pMF.getFilename();
				if (fileName != null) {
					FileContents fileContents = new FileContents(
					fileName, pMF.getParameter());
					fileArrList.add(fileContents);
				}
			}
		}

		
		LoadFile loadfile = new LoadFile(getServletContext());
		System.out.println("upppppppppname....................." + upname);
		loadfile.writeFile(fileArrList,upname.trim());
		htRequest.put("UploadedFiles", fileArrList);
		out.println("<table><tr><td class=bodyblue>File Uploaded Successfully<td></tr></table>");


		%> 
<script>window.opener.location.reload(); </script>
		
		<%
	} catch (Exception Ex) {
		Ex.printStackTrace();
	}
	}
%>



<%		}


	
			}
		catch(Exception e) {
				e.printStackTrace();
		}

		
		
		%>
		
</BODY>
</HTML> 


